package e2q.security.web.util;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import e2q.di.web.util.MvcUtil;
import e2q.security.domain.E2qSmDmjlb;
import e2q.security.domain.E2qSmDmjxx;
import e2q.web.orm.ICommonDao;

@Controller
public class Userpublic {
	@Autowired
	@Qualifier("commonDAOProxy")
	private ICommonDao dao;
		List<E2qSmDmjxx> cqupt_dmjxx;
		E2qSmDmjlb cqupt_dmjlb=null;
		@RequestMapping("/util/userstate.do")
		public ModelAndView getddd()
		{
			JSONArray jsonArray = new JSONArray();
//			String sqlApp = "from E2qSmApplication o ";
//			List<?> appList = dao.find(sqlApp);
			cqupt_dmjlb= (E2qSmDmjlb) dao.find("from E2qSmDmjlb e where e.id=10001").get(0);
			cqupt_dmjxx=dao.find("from E2qSmDmjxx e where e.e2qSmDmjlb.id=? and e.DMJXX_LBM=?",new Object[]{cqupt_dmjlb.getId(),cqupt_dmjlb.getLmb()});
			for (E2qSmDmjxx item : cqupt_dmjxx)
			{
				JSONObject object=new JSONObject();
				object.element("key", item.getDMJXX_DM());
				object.element("value", item.getDMJXX_MC());
				jsonArray.add(object);
			}
			return MvcUtil.jsonArrayModelAndView(jsonArray);
		}
}
